<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Change Password</title>
<link rel="stylesheet" type="text/css" href="css/loginstyle.css" />
<link rel="stylesheet" type="text/css" href="css/popup_css.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddaccordion.js"></script>
<script type="text/javascript">
ddaccordion.init({
	headerclass: "submenuheader",
	contentclass: "submenu",
	revealtype: "click", 
	mouseoverdelay: 200, 
	collapseprev: true, 
	defaultexpanded: [],
	onemustopen: false, 
	animatedefault: false, 
	persiststate: true, 
	toggleclass: ["", ""], 
	togglehtml: ["suffix", "<img src='images/plus.gif' class='statusicon' />", "<img src='images/minus.gif' class='statusicon' />"],
	animatespeed: "fast", 
	oninit:function(headers, expandedindices){ 
	},
	onopenclose:function(header, index, state, isuseractivated){ 
	}
});

	
	$(document).ready(function() {
		
		$('#pwd1').live("paste",function(e) {
			 e.preventDefault();

		 });

		 $('#pwd').live("cut copy paste",function(e) {
			 e.preventDefault();

			});
		
		$("#pass").blur(function(){
			 var pass= $("#pass").val();   
		    $.ajax({
				url : './mock/brokerPass',
				dataType: "json",
				contentType: 'application/json',			  
				  
				success : function(jsonData) {
					for(var a in jsonData){
					
						if(jsonData[a]["password"]!=pass){
							alert("You have Entered an incorrect Password.");
						}
					}
				}
			});
		  });
		
		$("#submit").click(function(event) { 
			if($("#pass").val()!='' && $("#pwd1").val()!='' ){
			var reqUrl="./user/UpdateBrokePwd";
			var p1=$("#pwd").val();  
			var p2=$("#pwd1").val();  
			if(p1==p2){
			var jsondata = JSON.stringify({ "password":$("#pwd").val()});
		$.ajax(
			  {
			  type: "POST",
			  url: reqUrl,
			  dataType: "json",
			  contentType: 'application/json',	  
			  data:jsondata, 
			  success: function(jsonResponse) { 
				  alert(jsonResponse["msg"]);
				  document.getElementById("pass").value="";
				  document.getElementById("pwd").value="";
				  document.getElementById("pwd1").value="";
			  }
			  
			});
			}else{
				alert("Password field does not matches with Confirm Password.");
				 document.getElementById("pass").value="";
				  document.getElementById("pwd").value="";
				  document.getElementById("pwd1").value="";
			}
			
			}	
			});
		
		 $('#close').click(function(){
		        parent.history.back();
		        return false;
		    });
		
	});
function formvalidation(){
	var error	=	false;
		if((document.getElementById('pass').value)==''){
			document.getElementById('opassErrorLable').innerHTML='Enter Current Password .';
			
			error	=	true;
		}
		
		 if((document.getElementById('pwd1').value)==''){
			document.getElementById('cpassErrorLable').innerHTML='Enter  Confirm Password.';
			error	=	true;
		}
		
		
		if(error==false){
			return true;
			}else{ 
			return false;
		}
}



</script>
<script language="javascript" type="text/javascript" src="js/niceforms.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" />
</head>
<body>
  <%@ include file="header.jsp" %>	

     
         <div class="login_form">
         
         <h3>Change Password.....</h3>
         <div style="float:right;">
         
      
        
   
         </div>
         <form action="./brokeChangePwd" method="post" class="niceform" id="changepwd">
         
                <fieldset>
                    <dl>
                        <dt><label for="email"><b><font color="red" size="3">*</font></b>Old Password:</label></dt>
                        <dd><input type="password" name="pass" id="pass" size="44" /></dd>
                         <div id="opassErrorLable"></div>   
                    </dl>
                    <dl>
                        <dt><label for="password">New Password:</label></dt>
                        <dd><input type="password" name="pwd" id="pwd" size="44" /></dd>
                    </dl>
                    <dl>
                        <dt><label for="password"><b><font color="red" size="3">*</font></b>Confirm Password:</label></dt>
                        <dd><input type="password" name="pwd1" id="pwd1" size="44" /></dd>
                          <div id="cpassErrorLable"></div>   
                    </dl>
                   
                    
                     <dl class="submit">
                    <input type="button" name="submit" id="submit" value="Submit" onclick="formvalidation();" />
                     <input type="reset" name="reset" id="reset" value="Reset" />
                     </dl>
                    <a class="close" href="#close" id="close"></a>
                </fieldset>
                  
         </form>
       
         </div>  
          
	


		
</body>
</html>